package com.example.demo.pojo;

public class Score2 extends Score {

    @Override
    public Double getToscore() {
        Double xyscore = getXyscore();
        Integer szscore = getSzscore();
        Integer kyscore = getKyscore();
        Integer sescore = getSescore();

        if (xyscore != null && szscore != null && kyscore != null && sescore != null) {
            return (xyscore + szscore + kyscore + sescore);
        }
        return null;
    }

    @Override
    public Double getXyscore() {
        Integer xycourseNum = getXycourseNum();
        Integer xytoScore = getXytoScore();

        if (xycourseNum != null && xycourseNum != 0 && xytoScore != null) {
            double xyscore = (double) xytoScore / xycourseNum * 0.2;
            if (xyscore > 20) {
                xyscore = 20.0;
            }
            return xyscore;
        }
        return null;
    }

    @Override
    public Integer getKyscore() {
        Integer kylwScore = getKylwScore();
        Integer kyzsScore = getKyzsScore();
        Integer kysmScore = getKysmScore();
        Integer kyjsScore = getKyjsScore();

        if (kylwScore != null && kyzsScore != null && kysmScore != null && kyjsScore != null) {
            int kyscore = kylwScore + kyzsScore + kysmScore + kyjsScore;
            if (kyscore > 30) {
                kyscore = 30;
            }
            return kyscore;
        }
        return null;
    }

    public Integer getTemp() {
        Double xyScore = getXyscore();
        Double toscore = getToscore();
        Integer szscore = getSzscore();

        if (toscore != null && szscore != null && xyScore >= 12) {
            if (toscore >= 90 && szscore >= 24) {
                return 1;
            } else if (toscore >= 80) {
                return 2;
            } else if (toscore >= 70) {
                return 3;
            }
        }
        return 0;
    }

}